#ifndef _EVENT_DEF_H_
#define _EVENT_DEF_H_

#include "bksevent.h"
#include "eventtype.h"
#include "bike.pb.h"
#include <ostream>

using namespace tutorial;

class MobileCodeReqEv : public BKSEvent{
public:
    MobileCodeReqEv(const std::string &mobile):BKSEvent(EVENT_MOBILE_GET_CODE_REQ, BKSEvent::generateSyn())
    {
        mreq.set_mobile(mobile);
    }

    virtual ~MobileCodeReqEv()
    {

    }

    virtual std::ostream &dump(std::ostream &out); 
    
    std::string get_mobile() const
    {
        return mreq.mobile();
    }

    virtual bool SerializeToArray(char *_write_msg_buf, u32 write_msg_len)
    {
        return mreq.SerializeToArray(_write_msg_buf, write_msg_len);
    }

    virtual i32 ByteSize()
    {
        return mreq.ByteSize();
    }

private:
    mobile_request mreq;
};

class MobileCodeRspEv : public BKSEvent{
public:
    MobileCodeRspEv(i32 code, i32 icode):BKSEvent(EVENT_MOBILE_CODE_RSP, BKSEvent::generateSyn())
    {
        mrsp.set_code(code);
        mrsp.set_icode(icode);
        mrsp.set_desc(getCodeReason(code));
    }

    virtual ~MobileCodeRspEv()
    {

    }

    i32 get_code() const
    {
        return mrsp.code();
    }

    i32 get_icode() const
    {
        return mrsp.icode();
    }

    std::string get_desc() const
    {
        return mrsp.desc();
    }

    virtual std::ostream &dump(std::ostream &out);

    virtual bool SerializeToArray(char *_write_msg_buf, u32 write_msg_len)
    {
        return mrsp.SerializeToArray(_write_msg_buf, write_msg_len);
    }

    virtual i32 ByteSize()
    {
        return mrsp.ByteSize();
    }

private:
    mobile_response mrsp;
};

class LoginReqEv : public BKSEvent{
public:
    LoginReqEv(const std::string &mobile, i32 icode):BKSEvent(EVENT_LOGIN_REQ, BKSEvent::generateSyn()){
        logreq.set_mobile(mobile);
        logreq.set_icode(icode);
    }
    std::string get_mobile() const{
        return logreq.mobile();
    }
    i32 get_icode() const{
        return logreq.icode();
    }
    virtual std::ostream &dump(std::ostream &out);

    virtual bool SerializeToArray(char *_write_msg_buf, u32 write_msg_len)
    {
        return logreq.SerializeToArray(_write_msg_buf, write_msg_len);
    }

    virtual i32 ByteSize()
    {
        return logreq.ByteSize();
    }
private:
    login_request logreq;
};

class LoginRspEv : public BKSEvent{
public:
    LoginRspEv(i32 code):BKSEvent(EVENT_LOGIN_RSP, BKSEvent::generateSyn()){
        logrsp.set_code(code);
        logrsp.set_desc(getCodeReason(code));
    }
    i32 get_code()const{
        return logrsp.code();
    }
    std::string get_desc()const{
        return logrsp.desc();
    }
    virtual std::ostream &dump(std::ostream &out);

    virtual bool SerializeToArray(char *_write_msg_buf, u32 write_msg_len)
    {
        return logrsp.SerializeToArray(_write_msg_buf, write_msg_len);
    }

    virtual i32 ByteSize()
    {
        return logrsp.ByteSize();
    }
private:
    login_response logrsp;
};

class ErrorEv : public BKSEvent{
public:
    ErrorEv():BKSEvent(EVENT_ERROR, BKSEvent::generateSyn())
    {

    }

    virtual ~ErrorEv()
    {

    }
};
#endif